<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Colourizer Test</title></head>
<body>
<h1>Crunchy Colourizer Test</h1>
<p>Here is the basic unstyled example we are using most often:</p>
<pre title="no_vlam">
for i in range(10):
    print i,
print "Hello World"
</pre>

<p>The following code should be styled properly</p>
<pre title="py_code">
for i in range(10):
    print i,
print "Hello World"
</pre>
<p>Another working example, this time with linenumbers starting at 1,
by default.</p>
<pre title="py_code linenumber">
for i in range(10):
    print i,
print "Hello World"
</pre>
<p>Same example, this time with linenumbers starting at 1 by explicit
setting of starting value.</p>
<pre title="py_code linenumber=1">
for i in range(10):
    print i,
print "Hello World"
</pre>
<p>Same example, this time with linenumbers starting at 100.</p>
<pre title="py_code linenumber=100">
for i in range(10):
    print i,
print "Hello World"
</pre>
<p>Yet another working example with a simulated interpreter code sample.</p>
<pre title="py_code">
&gt;&gt;&gt; for i in range(10):
...    print i,
&gt;&gt;&gt; print("Hello World")
</pre>
<p>Same as the previous one, but with some line numbers added,
default starting value of 1.</p>
<pre title="py_code linenumber">
&gt;&gt;&gt; for i in range(10):
...    print i,
&gt;&gt;&gt; print("Hello World")
</pre>
<p>Same as the previous one, but with explicit choice for
starting value of 1.  We also use <code>python_code</code> instead of
<code>py_code</code> for vlam keyword.</p>
<pre title="python_code linenumber=1">
&gt;&gt;&gt; for i in range(10):
...    print i,
&gt;&gt;&gt; print("Hello World")
</pre>
<p>Same as the previous one, but with
starting value of 100.</p>
<pre title="py_code linenumber=100">
&gt;&gt;&gt; for i in range(10):
...    print i,
&gt;&gt;&gt; print("Hello World")
</pre>
<p>The following code should NOT be styled properly, and some warning should
be given to the user.</p>
<pre title="py_code">
for i in range(10:
    print(i)
</pre>
<p>In versions up to 0.8.1, comments and linenumbers apparently did not mix
properly [overlapping <code>&lt;span&gt;</code> sometimes result in a small
interpreter prompt (i.e. in the same font size as the linenumber)].
In the following example, all interpreter prompts should appear the same.
In particular, compare the interpreter prompts on the first and second lines
which used not to be the same font size. </p>
<pre title="py_code linenumber">
&gt;&gt;&gt; # Comment on the first line.
&gt;&gt;&gt; for i in range(10):
...    print i,
&gt;&gt;&gt; print("Hello World")
&gt;&gt;&gt; # Another comment.
&gt;&gt;&gt; print("Hello World")
</pre>

<p>An interpreter session that ends with a comment, as in:
<pre title="py_code">
&gt;&gt;&gt; # this last statement is a comment
</pre>
used to be processed ("colourized") by Crunchy in such a way
that it resulted in non W3C compliant code - and Crunchy (i.e. the
elementtree handler) chokeed on it, and displayed a blank page.
This has been fixed.</p>

<p>Code inside a <code>&lt;pre&gt;</code> that contains html markup is
now processed properly.
<br/>
Here's an actual example using a <code>&lt;br/&gt;</code> rather than
an "\n" character to separate lines of code.
The actual code we use inside a <code>&lt;pre&gt;</code> element is:<br/>
<code>print "Hello world!"&lt;br/&gt;print "Crunchy rocks!"
</code><br/>
Here is how this example is processed by Crunchy:</p>
<pre title="py_code">
print "Hello world!"<br/>print "Crunchy rocks!"
</pre>
<p>Both lines should appear as separate Python statements.
</p>
<p>The following is another "bare"  (&lt;pre&gt;) containing some
pre-marked up code, which has been formatted "by hand".</p>
<pre>
&gt;&gt;&gt; <span class="py_keyword">for</span> i <span class="py_keyword">in</span> range(3):
...     <span class="py_keyword">print</span> "Hello world!"
...
"Hello world!"
"Hello world!"
"Hello world!"
</pre>
<p>Crunchy overrides non-marked up (no vlam) elements by default, and inserts an interactive
element ("interpreter" by default, which can be over-riden by a user's choice). We can
specify that the original styling be retained by having the "no_vlam" option</p>
<pre title="no_vlam">
&gt;&gt;&gt; <span class="py_prompt">for</span> i <span class="py_prompt">in</span> range(3):
...     <span class="py_prompt">print</span> "Hello world!"
...
"Hello world!"
"Hello world!"
"Hello world!"
</pre>
<p>And here is the same example, this time processed by Crunchy (i.e.
existing formatting removed, and new one added.)</p>
<pre title="py_code">
&gt;&gt;&gt; <span class="py_keyword">for</span> i <span class="py_keyword">in</span> range(3):
...     <span class="py_keyword">print</span> "Hello world!"
...
"Hello world!"
"Hello world!"
"Hello world!"
</pre>

<p>A styling example (taken from a website) with pre-formatted code that included linenumbers;
the changing indentation when the line number goes to 2 digits causes some
parsing problems for Crunchy</p>
<pre title="py_code">
  1 import random
  2 import pygame
  3 from gfx import gl, array, ext
  4
  5
  6 def main():
  7     pygame.init()
  8     flags =  pygame.OPENGL|pygame.DOUBLEBUF|pygame.HWSURFACE
  9     pygame.display.set_mode((800,600), flags)
 10 
</pre>

<p>Same example as above, but the indentation has been made to stay constant</p>
<pre title="py_code">
  1 import random
  2 import pygame
  3 from gfx import gl, array, ext
  4
  5
  6 def main():
  7     pygame.init()
  8     flags =  pygame.OPENGL|pygame.DOUBLEBUF|pygame.HWSURFACE
  9     pygame.display.set_mode((800,600), flags)
  10 
</pre>

<p>Same faulty example as above but with an interpreter inserted</p>
<pre title="interpreter">
  1 import random
  2 import pygame
  3 from gfx import gl, array, ext
  4
  5
  6 def main():
  7     pygame.init()
  8     flags =  pygame.OPENGL|pygame.DOUBLEBUF|pygame.HWSURFACE
  9     pygame.display.set_mode((800,600), flags)
 10 
</pre>

<p> Some examples using the <code>&lt;code&gt;</code> element, as in
<code title="py_code">print "Hello world!"</code> and, with line numbering,
<code title="python_code linenumber">print "How are you?"</code> as well
as with fake interpreter prompt and line number starting at 999.
<code title="python_code linenumber=999">&gt;&gt;&gt; print("Goodbye!")</code></p>
<p>There used to be a missing part of a sentence between each code samples.
This was a problem with a dropped "ElementTree tail".</p>
<h2>Bugs</h2>
<ul>
  <li>There are no known bugs.</li>
</ul>
<p><a href="index.html">Back to the test index</a></p>
</body>
</html>
